@extends('layouts.default') @section('main')
<link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/themes/default/default.css" />
<link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.css" />
<script src="{{URL::asset('js/')}}/kindeditor-4.1.7/kindeditor.js" type="text/javascript"></script> 
<script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/lang/zh_CN.js"></script> 
<script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.js"></script>
<script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
<script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
<script src="{{URL::asset('js/My97DatePicker/')}}/WdatePicker.js"></script> 
<script>
KindEditor.ready(function(K) {

		var editor1 = K.create('#intro', {
			uploadJson: "{{url('kindedit/upload')}}",
			fileManagerJson: "{{url('kindedit/manager')}}",
			allowFileManager: true,
			afterBlur: function() {
				this.sync();
			},
			items: ['source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', 'image', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'table', 'hr', 'emoticons', 'pagebreak', 'anchor', 'link', 'unlink', '|']
		});
		
});
</script>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="{{url('ad/index')}}"
				class="tip-bottom">广告管理</a> <a href="#" class="current">新增广告</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span9">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
						<h5>新增广告</h5>
					</div>
					<div class="widget-content nopadding">
						<form action="{{url('ad/insert')}}" method="post"
							class="form-horizontal" id="adForm">
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>广告名称 :</label>
								<div class="controls">
									<input type="text" class="span11" name="title"
										placeholder="广告名称" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>广告类型 :</label>
								<div class="controls">
									<select name="type">
										@foreach($types as $type)
					                  <option value="{{$type->code}}">{{$type->name}}</option>
					                  	@endforeach
					                </select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>链接地址 :</label>
								<div class="controls">
									<input type="text" class="span11" name="link_url"
										placeholder="链接地址" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>图片地址 :</label>
								<div class="controls">
									<input type="hidden" class="span11" name="image"
										placeholder="图片地址" />
                                    <img src="" width="120px" name="image" height="120px"/>

                                    <a href="javascript:void(0);" id="uploadImageBtn"   onclick="javascript:openBrowse('uploadImageBtn','uploadImage');">点击上传</a>
                                        <input type="file" id="uploadImage" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadImage','image')"/>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>广告描述 :</label>
								<div class="controls">
									<textarea class="span11" name="intro" ></textarea>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">点击数 :</label>
								<div class="controls">
									<input type="text" class="span11" name="click_count"
										placeholder="点击数" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">开始时间 :</label>
								<div class="controls">
									<input type="text" class="span11" name="start_time"
										placeholder="开始时间" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">过期时间 :</label>
								<div class="controls">
									<input type="text" class="span11" name="expired_time"
										placeholder="过期时间" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>背景图片 :</label>
								<div class="controls">
									<input type="hidden" class="span11" name="bg_image"
										placeholder="背景图片" />
                                    <img src="" width="120px" name="bg_image" height="120px"/>

                                    <a href="javascript:void(0);" id="uploadBgimageBtn"   onclick="javascript:openBrowse('uploadBgimageBtn','uploadBgimage');">点击上传</a>
                                        <input type="file" id="uploadBgimage" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBgimage','bg_image')"/>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">排序 :</label>
								<div class="controls">
									<input type="text" class="span11" name="sort"
										placeholder="排序" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><span class="redD">*</span>状态 :</label>
								<div class="controls">
									<label> <input type="radio" name="status" value="1" /> 通过
									</label> <label> <input type="radio" name="status" value="0" checked="checked" /> 等待
									</label>
								</div>
							</div>
							<div class="form-actions">
								<button type="button" id="doSave" class="btn btn-success">保存</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
$("#doSave").click(function(){
	ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
		if(data.status){
            alert(data.message);
            window.location.href = data.forwardUrl;
		}else{
			alert(data.message);
		}
	});
});
</script>
@stop
